<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
      function Person(name, age, sex, height, weight) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.height = height;
        this.weight = weight;
      }
      Person.prototype.eat = function () {
        console.log(this.name + '应该吃早饭');
      }
      function Student(name, age, sex, height, weight, score) {
        this.score = score;
        // 继承
        Person.call(this, name, age, sex, height, weight);
      }
      Student.prototype = new Person();
      Student.prototype.study = function () {
        console.log(this.score + '分数');
      }
      var yejianxin = new Student('叶建新', 18, '男', 180, 50, 80);
      var maxinxin = new Student('马鑫鑫', 2, '女', 180,50,100);
      // console.log(maxinxin.name);
      // maxinxin.eat();
      // maxinxin.eat();
      // maxinxin.study();
      yejianxin.eat();
      yejianxin.study();
      // 为什么要用构造函数继承？还不能用方法，只能继承属性，为什么还要用呢？
      // 答：为了实现个体的不同，每个实例化出来的Student有不同的名字年龄性别等
      // 想要实现方法可以用，只需要把原型指向改变即可
      // 互补，组合式继承，原型指向 + 构造函数指向

    </script>
  </body>
</html>
